import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*
testCase = "DBshop006_删除取消的订单"
# 1.点击销售管理订单管理界面。
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"销售管理","订单管理")
s=firefox.find_element_by_xpath("//body").text
l="订单数\："
r="\)"
num1=reGetString(s,l,r)
# 2.在订单号查询框输入orderID，点击“搜索”按钮。
rootPath = get_pro_rootpath() #获取项目绝对路径
filePath = rootPath+r'\public\order1.txt' #拼接文件路径
orderID = readFile(filePath) #读取文件内容
print(orderID) #打印编号
DBshopSearchOrderID(firefox,orderID)
# 3.点击编辑查看，点击删除
firefox.find_element_by_link_text("编辑查看").click()
firefox.find_element_by_link_text("删除订单").click()
firefox.switch_to.alert.accept()
time.sleep(3)
# 断言
s=firefox.find_element_by_xpath("//body").text
l="订单数："
r="\)"
num=reGetString(s,l,r)
print(num)
if  num == "0":
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(firefox)
firefox.quit()
